@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500&display=swap');

* { box-sizing: border-box; }

:root {
    --app-bg: #101827;
    --sidebar: rgba(21, 30, 47,1);
    --sidebar-main-color: #fff;
    --table-border: #1a2131;
    --table-header: #1a2131;
    --app-content-main-color: #fff;
    --sidebar-link: #fff;
    --sidebar-active-link: #1d283c;
    --sidebar-hover-link: #1a2539;
    --action-color: #2869ff;
    --action-color-hover: #6291fd;
    --app-content-secondary-color: #1d283c;
    --filter-reset: #2c394f;
    --filter-shadow: rgba(16, 24, 39, 0.8) 0px 6px 12px -2px, rgba(0, 0, 0, 0.3) 0px 3px 7px -3px;
}

.light:root {
    --app-bg: #fff;
    --sidebar: #f3f6fd;
    --app-content-secondary-color: #f3f6fd;
    --app-content-main-color: #1f1c2e;
    --sidebar-link: #1f1c2e;
    --sidebar-hover-link: rgba(195, 207, 244, 0.5);
    --sidebar-active-link: rgba(195, 207, 244, 1);
    --sidebar-main-color: #1f1c2e;
    --filter-shadow: rgba(99, 99, 99, 0.2) 0px 2px 8px 0px;
}

$font-small: 14px;
$font-medium: 16px;
$font-large: 24px;

body, html {
    margin: 0;
    padding: 0;
    height: 100%;
    width: 100%;
}

body {
    overflow: hidden;
    font-family: 'Poppins', sans-serif;
    background-color: var(--app-bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.app-container {
    border-radius: 4px;
    width: 100%;
    height: 100%;
    max-height: 100%;
    max-width: 1280px;
    display: flex;
    overflow: hidden;
    box-shadow: rgba(99, 99, 99, 0.2) 0px 2px 8px 0px;
    max-width: 2000px;
    margin: 0 auto;
}

.sidebar {
    flex-basis: 200px;
    max-width: 200px;
    flex-shrink: 0;
    background-color: var(--sidebar);
    display: flex;
    flex-direction: column;

    &-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 16px;
    }

    &-list {
        list-style-type: none;
        padding: 0;

        &-item {
            position: relative;
            margin-bottom: 4px;

            a {
                display: flex;
                align-items: center;
                width: 100%;
                padding: 10px 16px;
                color: var(--sidebar-link);
                text-decoration: none;
                font-size: $font-small;
                line-height: 24px;
            }

            svg { margin-right: 8px; }

            &:hover { background-color: var(--sidebar-hover-link); }

            &.active {
                background-color: var(--sidebar-active-link);

                &:before {
                    content: '';
                    position: absolute;
                    right: 0;
                    background-color: var(--action-color);
                    height: 100%;
                    width: 4px;
                }
            }
        }
    }

    @media screen and (max-width: 1024px) {&{
        display: none;
    }}
}

.mode-switch {
    background-color: transparent;
    border: none;
    padding: 0;
    color: var(--app-content-main-color);
    display: flex;
    justify-content: center;
    align-items: center;
    margin-left: auto;
    margin-right: 8px;
    cursor: pointer;

    .moon {
        fill: var(--app-content-main-color);
    }
}

.mode-switch.active .moon {
    fill: none;
}

.account-info {
    display: flex;
    align-items: center;
    padding: 16px;
    margin-top: auto;

    &-picture {
        width: 32px;
        height: 32px;
        border-radius: 50%;
        overflow: hidden;
        flex-shrink: 0;

        img {
            width: 100%;
            height: 100%;
            object-fit: cover;
        }
    }

    &-name {
        font-size: $font-small;
        color: var(--sidebar-main-color);
        margin: 0 8px;
        overflow: hidden;
        max-width: 100%;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    &-more {
        color: var(--sidebar-main-color);
        padding: 0;
        border: none;
        background-color: transparent;
        margin-left: auto;
    }
}

.app-icon {
    color: var(--sidebar-main-color);

    svg {
        width: 24px;
        height: 24px;
    }
}

.app-content {
    padding: 16px;
    background-color: var(--app-bg);
    height: 100%;
    flex: 1;
    max-height: 100%;
    display: flex;
    flex-direction: column;

    &-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 0 4px;
    }

    &-headerText {
        color: var(--app-content-main-color);
        font-size: $font-large;
        line-height: 32px;
        margin: 0;
    }

    &-headerButton {
        background-color: var(--action-color);
        color: #fff;
        font-size: $font-small;
        line-height: 24px;
        border: none;
        border-radius: 4px;
        height: 32px;
        padding: 0 16px;
        transition: .2s;
        cursor: pointer;

        &:hover {
            background-color: var(--action-color-hover);
        }
    }

    &-actions {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 16px 4px;

        &-wrapper {
            display: flex;
            align-items: center;
            margin-left: auto;
        }

        @media screen and (max-width: 520px) {&{
            flex-direction: column;

            .search-bar { max-width: 100%; order: 2; }
            .app-content-actions-wrapper { padding-bottom: 16px; order: 1; }
        }}
    }
}

@mixin searchIcon($color) {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23#{$color}' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='feather feather-search'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E");
}

.search-bar {
    background-color: var(--app-content-secondary-color);
    border: 1px solid var(--app-content-secondary-color);
    color: var(--app-content-main-color);
    font-size: $font-small;
    line-height: 24px;
    border-radius: 4px;
    padding: 0px 10px 0px 32px;
    height: 32px;
    @include searchIcon('fff');
    background-size: 16px;
    background-repeat: no-repeat;
    background-position: left 10px center;
    width: 100%;
    max-width: 320px;
    transition: .2s;

    .light & { @include searchIcon('1f1c2e'); }

    &:placeholder { color: var(--app-content-main-color); }

    &:hover {
        border-color: var(--action-color-hover);
        @include searchIcon('6291fd');
    }

    &:focus {
        outline: none;
        border-color: var(--action-color);
        @include searchIcon('2869ff');
    }
}

.action-button {
    border-radius: 4px;
    height: 32px;
    background-color: var(--app-content-secondary-color);
    border: 1px solid var(--app-content-secondary-color);
    display: flex;
    align-items: center;
    color: var(--app-content-main-color);
    font-size: $font-small;
    margin-left: 8px;
    cursor: pointer;

    span { margin-right: 4px; }

    &:hover {
        border-color: var(--action-color-hover);
    }

    &:focus, &.active {
        outline: none;
        color: var(--action-color);
        border-color: var(--action-color);
    }
}

.filter-button-wrapper {
    position: relative;
}

@mixin arrowDown($color) {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23#{$color}' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' class='feather feather-chevron-down'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
}

.filter-menu {
    background-color: var(--app-content-secondary-color);
    position: absolute;
    top: calc(100% + 16px);
    right: -74px;
    border-radius: 4px;
    padding: 8px;
    width: 220px;
    z-index: 2;
    box-shadow: var(--filter-shadow);

    visibility: hidden;
    opacity: 0;
    transition: .2s;

    &:before {
        content: '';
        position: absolute;
        width: 0;
        height: 0;
        border-left: 5px solid transparent;
        border-right: 5px solid transparent;

        border-bottom: 5px solid var(--app-content-secondary-color);
        bottom: 100%;
        left: 50%;
        transform: translatex(-50%);
    }

    &.active {
        visibility: visible;
        opacity: 1;
        top: calc(100% + 8px);
    }

    label {
        display: block;
        font-size: $font-small;
        color: var(--app-content-main-color);
        margin-bottom: 8px;
    }

    select {
        appearance: none;
        @include arrowDown('fff');
        background-repeat: no-repeat;
        padding: 8px 24px 8px 8px;
        background-position: right 4px center;
        border: 1px solid var(--app-content-main-color);
        border-radius: 4px;
        color: var(--app-content-main-color);
        font-size: 12px;
        background-color: transparent;
        margin-bottom: 16px;
        width: 100%;
        option { font-size: 14px; }

        .light & {
            @include arrowDown('1f1c2e');
        }

        &:hover {
            border-color: var(--action-color-hover);
        }

        &:focus, &.active {
            outline: none;
            color: var(--action-color);
            border-color: var(--action-color);
            @include arrowDown('2869ff');
        }
    }
}

.filter-menu-buttons {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.filter-button {
    border-radius: 2px;
    font-size: 12px;
    padding: 4px 8px;
    cursor: pointer;
    border: none;
    color: #fff;

    &.apply {
        background-color: var(--action-color);
    }

    &.reset {
        background-color: var(--filter-reset);
    }
}

.products-area-wrapper {
    width: 100%;
    max-height: 100%;
    overflow: auto;
    padding: 0 4px;
}

.tableView {
    .products-header {
        display: flex;
        align-items: center;
        border-radius: 4px;
        background-color: var(--app-content-secondary-color);
        position: sticky;
        top: 0;
    }

    .products-row {
        display: flex;
        align-items: center;
        border-radius: 4px;

        &:hover {
            box-shadow: var(--filter-shadow);
            background-color: var(--app-content-secondary-color);
        }

        .cell-more-button {
            display: none;
        }
    }

    .product-cell {
        flex: 1;
        padding: 8px 16px;
        color: var(--app-content-main-color);
        font-size: $font-small;
        display: flex;
        align-items: center;

        img {
            width: 32px;
            height: 32px;
            border-radius: 6px;
            margin-right: 6px;
        }

        @media screen and (max-width: 780px) {&{
            font-size: 12px;
            &.image span { display: none; }
            &.image { flex: 0.2; }
        }}

        @media screen and (max-width: 520px) {&{
            &.category, &.sales {
                display: none;
            }
            &.status-cell { flex: 0.4; }
            &.stock, &.price { flex: 0.2; }
        }}

        @media screen and (max-width: 480px) {&{
            &.stock { display: none; }
            &.price { flex: 0.4; }
        }}
    }

    .sort-button {
        padding: 0;
        background-color: transparent;
        border: none;
        cursor: pointer;
        color: var(--app-content-main-color);
        margin-left: 4px;
        display: flex;
        align-items: center;

        &:hover { color: var(--action-color); }
        svg { width: 12px; }
    }

    .cell-label {
        display: none;
    }
}

.status {
    border-radius: 4px;
    display: flex;
    align-items: center;
    padding: 4px 8px;
    font-size: 12px;

    &:before {
        content: '';
        width: 4px;
        height: 4px;
        border-radius: 50%;
        margin-right: 4px;
    }

    &.active {
        color: #2ba972;
        background-color: rgba(43, 169, 114, 0.2);

        &:before {
            background-color: #2ba972;
        }
    }

    &.disabled {
        color: #59719d;
        background-color: rgba(89, 113, 157, 0.2);

        &:before {
            background-color: #59719d;
        }
    }
}

.gridView {
    display: flex;
    flex-wrap: wrap;
    margin: 0 -8px;

    @media screen and (max-width: 520px) {&{
        margin: 0;
    }}

    .products-header {
        display: none;
    }

    .products-row {
        margin: 8px;
        width: calc(25% - 16px);
        background-color: var(--app-content-secondary-color);
        padding: 8px;
        border-radius: 4px;
        cursor: pointer;
        transition: transform .2s;
        position: relative;

        &:hover {
            transform: scale(1.01);
            box-shadow: var(--filter-shadow);

            .cell-more-button {
                display: flex;
            }
        }

        @media screen and (max-width: 1024px) {&{
            width: calc(33.3% - 16px);
        }}

        @media screen and (max-width: 820px) {&{
            width: calc(50% - 16px);
        }}

        @media screen and (max-width: 520px) {&{
            width: 100%;
            margin: 8px 0;

            &:hover {
                transform: none;
            }
        }}

        .cell-more-button {
            border: none;
            padding: 0;
            border-radius: 4px;
            position: absolute;
            top: 16px;
            right: 16px;
            z-index: 1;
            display: flex;
            align-items: center;
            justify-content: center;
            width:24px;
            height: 24px;
            background-color: rgba(16, 24, 39, 0.7);
            color: #fff;
            cursor: pointer;
            display: none;
        }
    }

    .product-cell {
        color: var(--app-content-main-color);
        font-size: $font-small;
        margin-bottom: 8px;

        &:not(.image) {
            display: flex;
            align-items: center;
            justify-content: space-between;
        }

        &.image  span {
            font-size: 18px;
            line-height: 24px;
        }

        img {
            width: 100%;
            height: 140px;
            object-fit: cover;
            border-radius: 4px;
            margin-bottom: 16px;
        }
    }

    .cell-label { opacity: 0.6; }
}